package br.com.massai.model.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.envers.Audited;

@Entity
@Audited
@Table(name = "UNIT_MEASURE")
@NamedQueries({
	@NamedQuery(name = "UnitMeasure.find", query = "SELECT u FROM UnitMeasure u"),
	@NamedQuery(name = "UnitMeasure.duplicate", query = "SELECT COUNT(u) FROM UnitMeasure u WHERE LOWER(u.acronym) = LOWER(:acronym)")
})
public class UnitMeasure extends GenericEntity {

	private static final long serialVersionUID = -6230331798098688517L;

	@Id
	@SequenceGenerator(name = "seqUnitMeasure", sequenceName = "seq_unit_measure", allocationSize = 1)
	@GeneratedValue(generator = "seqUnitMeasure", strategy = GenerationType.SEQUENCE)
	private Long id;
	
	@Column(name = "ACRONYM", length = 10, nullable = false, columnDefinition = "VARCHAR(10)")
	private String acronym;
	
	@Column(name = "NAME_MEASURE", length = 100, nullable = false, columnDefinition = "VARCHAR(100)")
	private String nameMeasure;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getAcronym() {
		return acronym;
	}

	public void setAcronym(String acronym) {
		this.acronym = acronym;
	}

	public String getNameMeasure() {
		return nameMeasure;
	}

	public void setNameMeasure(String nameMeasure) {
		this.nameMeasure = nameMeasure;
	}
}